package com.zxy.supplier_system.server.controller

import com.zxy.supplier_system.server.utils.tencent.position.*
import org.springframework.data.domain.Pageable
import org.springframework.web.bind.annotation.GetMapping
import org.springframework.web.bind.annotation.RequestMapping
import org.springframework.web.bind.annotation.RestController

@RestController
@RequestMapping("tencentPositions")
class TencentPositionController(
    private val tencentWebPositionClient: TencentWebPositionClient,
) {

    @GetMapping("searchPlaceRegion")
    fun searchPlaceRegion(keyword:String, region:String, pageable: Pageable): SearchPlaceResponse {
        return tencentWebPositionClient.searchPlace(keyword,"region($region,1)",pageable.pageSize,pageable.pageNumber+1)
    }

    // TODO  130000	限定分类 购物
    @GetMapping("searchSuggestion")
    fun searchSuggestion(keyword:String,region: String?,pageable: Pageable): SearchSuggestionResponse {
        return tencentWebPositionClient.searchSuggestion(keyword,region,pageable)
    }

    @GetMapping("searchPlaceNearby")
    fun searchPlaceNearby(keyword:String, longitude:Double, latitude: Double, pageable: Pageable): SearchPlaceResponse {
        return tencentWebPositionClient.searchPlace(keyword,"nearby($latitude,$longitude,10000)",pageable.pageSize,pageable.pageNumber+1)
    }

}